package com.nettest.util;

import java.util.Map;

import org.apache.struts2.util.StrutsTypeConverter;

public class MyStringConvert extends StrutsTypeConverter {

	@SuppressWarnings("rawtypes")
	@Override
	public Object convertFromString(Map context, String[] values, Class toClass) {
		if (values == null || values.length == 0) {
			return null;
		}
		String dateString = values[0];
		if (StringUtils.isEmpty(dateString)) {
			return null;
		}
		return dateString;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public String convertToString(Map context, Object o) {
		if (o instanceof String[]) {
			String[] array = (String[]) o;
			if (StringUtils.isEmpty(array[0])) {
				return null;
			}
			return array[0];
		}
		return "";
	}
}
